

from fastapi import APIRouter,Depends
from starlette.responses import StreamingResponse


from app.business.rag_chat import rag_chatDetailBiz_stream
from app.middleware.auth import JWTUser, get_current_user

rag_chat_router = APIRouter()
_active = True  # 激活状态


@rag_chat_router.post("/chat_stream",
    summary="聊天接口stream",)
async def chat_stream(  rag_chat: rag_chatDetailBiz_stream,
        # current_user: JWTUser = Depends(get_current_user)
                        ):
    return StreamingResponse(rag_chat.chat_rag(), media_type="text/event-stream")



@rag_chat_router.post("/chat_stream_poc",
    summary="聊天接口",)
async def chat_stream(  rag_chat: rag_chatDetailBiz_stream,
        # current_user: JWTUser = Depends(get_current_user)
                        ):
    rag_chat.session_id=5
    result = await rag_chat.chat_rag_poc()
    return result


@rag_chat_router.post("/chat_stream_poc_only_rag",
    summary="聊天接口only_rag",)
async def chat_stream(  rag_chat: rag_chatDetailBiz_stream,
        # current_user: JWTUser = Depends(get_current_user)
                        ):
    result = await rag_chat.chat_rag_poc_rag_only()
    return result





